package com.yuanfengerp.SalesOrder.controller;

import com.alibaba.fastjson.JSON;
import com.yuanfengerp.SalesOrder.model.SalesOrder;
import com.yuanfengerp.SalesOrder.service.ISalesOrderService;
import com.yuanfengerp.publicUtil.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class SalesOrderController {
    @Autowired
    private ISalesOrderService isos;
    // 获取仓库列表
    @PostMapping("/getWarehouseList")
    public String getWarehouseList(){
        return JSON.toJSONString(isos.getWarehouseList());
    }
    //根据仓库编号和仓库名称获取仓库信息
    @PostMapping("/getWarehouse")
    public String getWarehouse(String warehouse_ID,String warehouse_name){
        return JSON.toJSONString(isos.getWarehouse(warehouse_ID,warehouse_name));
    }
    //获取客户列表
    @PostMapping("/getCustomerList")
    public String getCustomerList(){
        return JSON.toJSONString(isos.getCustomerList());
    }
    //根据客户编号和客户名称获取客户信息
    @PostMapping("/getCustomer")
    public String getCustomer(String customer_ID,String customer_name){
        return JSON.toJSONString(isos.getCustomer(customer_ID,customer_name));
    }
    //获取销售订单列表
    @PostMapping("/getSalesOrderList")
    public String getSalesOrderList(int pageSize,int offset){
        return JSON.toJSONString(isos.getSalesOrderList(pageSize,offset));
    }
    //根据产品编号、仓库编号、客户编号获取销售订单
    @PostMapping("/getSalesOrder")
    public String getSalesOrder(String prod_id,String warehouse_ID,String customer_id){
        return JSON.toJSONString(isos.getSalesOrder(prod_id,warehouse_ID,customer_id));
    }
    //添加销售订单
    @PostMapping("/insertSalesOrder")
    public Result<SalesOrder> insertSalesOrder(SalesOrder salesOrder){
        return isos.insertSalesOrder(salesOrder);
    }
    //更新销售订单状态
    @PostMapping("/updateStatus")
    public String updateStatus(int status){
        return isos.updateStatus(status);
    }
}
